//
//  TSViewAddToDiffViewController.m
//  AppCommonJSCollect
//
//  Created by qian on 2023/10/20.
//  Copyright © 2023 dvlproad. All rights reserved.
//

#import "TSViewAddToDiffViewController.h"
#import <Masonry/Masonry.h>
#import "TSSharedNormalViewContainer.h"

#import "TSMineHomeViewController.h"

@interface TSViewAddToDiffViewController () {
    
}
@property (nonatomic, strong) UIButton *goButton;
@property (nonatomic, assign) NSInteger currentPageIndex;

@end

@implementation TSViewAddToDiffViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1.0]; // #f5f5f5
    
    self.currentPageIndex = [[NSUserDefaults standardUserDefaults] integerForKey:@"pageIndex"];
    self.title = [NSString stringWithFormat:@"第%ld页", self.currentPageIndex+1];
    [self setupViews];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    TSSharedNormalViewContainer *sharedView = [TSSharedNormalViewContainer sharedInstance];

    
    [self.view addSubview:sharedView];
    [sharedView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.left.mas_equalTo(self.view).mas_offset(10);
        make.top.mas_equalTo(self.goButton.mas_bottom).mas_offset(20);
        make.bottom.mas_equalTo(self.view).mas_offset(20);
    }];
}

- (void)setupViews {
    UIButton *goButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [goButton setBackgroundColor:UIColor.redColor];
    [goButton setTitle:@"进入下一页" forState:UIControlStateNormal];
    [goButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [goButton addTarget:self action:@selector(goNext) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:goButton];
    [goButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.mas_topLayoutGuideBottom).mas_offset(10);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(30);
    }];
    self.goButton = goButton;
}

- (void)goNext {
    [[NSUserDefaults standardUserDefaults] setInteger:self.currentPageIndex+1 forKey:@"pageIndex"];
    TSViewAddToDiffViewController *viewController = [[TSViewAddToDiffViewController alloc] init];
    [self.navigationController pushViewController:viewController animated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
